# -*- encoding: utf-8 -*-
"""

PyCharm 22堆积图的绘制
2024年 10月 28日 14:35
coded by wenyang
文件的主要内容


"""
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np


def main():
    # 设置字体
    mpl.rcParams['font.sans-serif'] = ['SimHei']
    mpl.rcParams['axes.unicode_minus'] = False
    x = np.array([1, 2, 3, 4, 5])
    y = np.random.randint(1, 20, x.size)
    y1 = np.random.randint(1, 25, x.size)
    plt.xlabel("试卷的难度")
    plt.ylabel("试卷的数量")
    plt.title("试卷的数量和难度的关系")
    plt.bar(x, y, color = "red", align = "center", alpha = 0.5, edgecolor = "yellow", tick_label = ["A", "B", "C", "D", "E"], label = "试卷的数量和难度的关系", hatch = "x")
    plt.bar(x, y, color = "blue", bottom = y, align = "center", alpha = 0.6, edgecolor = "green", tick_label = ["A", "B", "C", "D", "E"], label = "试卷的数量和难度的关系", hatch = "o")
    plt.legend()
    plt.show()

if __name__ == "__main__":
    main()
